﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;
using WXYW.DAL;

namespace WXYW
{
    public partial class UpgradeConfirmProduct : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitialPage();
            }
        }

        private void InitialPage()
        {
            UpgradeService service = new UpgradeService();
            UpgradeForm upForm = service.GetProductDetailForm(long.Parse(Request.QueryString[Constants.QUERYSTR_UPGRADE_ID]));
            productTypeLabel.Text = upForm.ApplicationProduct.ProductType.ProductTypeName;
            serialNumberLabel.Text = upForm.ApplicationProduct.ProductSerialNumber;
            problemTypeLabel.Text = upForm.ApplicationProduct.ProblemType.Name;
            decriptionLabel.Text = upForm.ApplicationProduct.ProductProblemDescription;
            appearanceLabel.Text = upForm.ApplicationProduct.ProductAppearance;
            repairTypeLabel.Text = upForm.ApplicationProduct.ProductRepairType;
            examineResultLabel.Text = upForm.ApplicationProduct.Remark;
            upgradeReason.Text = upForm.UpgradeReason;

            rmaLabel.Text = upForm.ApplicationProduct.ApplicationForm.ApplicationCode;
            applyLabel.Text = upForm.User.ContactPerson;
        }

        protected void confirmLinkButton_Click(object sender, EventArgs e)
        {
            try
            {
                UpgradeService service = new UpgradeService();
                UpgradeForm upForm = service.GetProductDetailForm(long.Parse(Request.QueryString[Constants.QUERYSTR_UPGRADE_ID]));
                upForm.Status = "升级-待派单";
                upForm.ReceiveTime = DateTime.Now;
                upForm.ReceiveComment = receiveCommentTextBox.Text;
                service.Update(upForm);

                ClientScript.RegisterStartupScript(this.GetType(), "tip", "alert('成功确认收货');location.href='UpgradeNeedConfirmProduct.aspx';", true);
            }
            catch (Exception ex)
            {
                LogUtility.LogUtilityIntance.LogException(ex, "UpgradeConfirmProduct.aspx::confirmLinkButton_Click");
                throw ex;
            }
        }
    }
}
